﻿/* Copyright © Hauer Engineering 2012 */


// Entity Relationship Designer
var ERD = function (options)
{
    var defaultOptions =
        {
            // element (and its descendants) to which to apply ERD
            el: null,
            // service URL
            serviceUrl: null
        };

    if (!options)
        $.error('ERD options are not defined.');

    $.extend(true, defaultOptions, options);

    // create view model
    var viewModel = new ERDViewModel(
        {
            serviceUrl: defaultOptions.serviceUrl
        });

    // add graph functionality
    var graph = new ERDGraph(
        {
            el: defaultOptions.el,
            viewModel: viewModel
        });

    // load domains
    viewModel.fk.loadDomains();

    // apply KO bindings
    ko.applyBindings(viewModel);

    // add tabs
    defaultOptions.el.find('.tabsContainer-group').tabs();
};